/**
Copyright 2010, David Keyes.  All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License. You may obtain
a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and 
limitations under the License. 

*/
package com.keyes.license.api.model;

import java.util.SortedMap;
import java.util.TreeMap;

import com.keyes.protobuf.CodedInputStream;

public class App extends ProtoBufBase {

  public App(CodedInputStream pCis) {
    super(pCis);
  }

  @Override
  public SortedMap<Integer, ProtoBufMapping> calculateMappings() {
    
    SortedMap<Integer, ProtoBufMapping> lRet = new TreeMap<Integer, ProtoBufMapping>();
    
    lRet.put(1, new ProtoBufMapping(1, "id", PROTOBUFTYPE.LENGTHDELIM_STRING, null));
    lRet.put(2, new ProtoBufMapping(2, "title",  PROTOBUFTYPE.LENGTHDELIM_STRING, null));
    lRet.put(3, new ProtoBufMapping(3, "appType",  PROTOBUFTYPE.VARINT, null));
    
    lRet.put(12, new ProtoBufMapping(12, "extendedInfo",  PROTOBUFTYPE.START_GROUP, null));
    
    lRet.put(22, new ProtoBufMapping(22, "creatorId",  PROTOBUFTYPE.LENGTHDELIM_STRING, null));
    lRet.put(24, new ProtoBufMapping(24, "packageName",  PROTOBUFTYPE.LENGTHDELIM_STRING, null));

    lRet.put(34, new ProtoBufMapping(34, "purchased",  PROTOBUFTYPE.VARINT, null));

    
    return lRet;
  }

  public String getId(){
    return (String) mIdMappedValues.get(1);
  }

  public String getTitle() {
    return (String) mIdMappedValues.get(2);
  }
  
  public int getAppType() {
    return (Integer) mIdMappedValues.get(3);
  }
  
  public String getCreatorId(){
    return (String) mIdMappedValues.get(22);
  }
  
  public String getPackageName(){
    return (String) mIdMappedValues.get(24);
  }
  
  public boolean isPurchased(){
    boolean lRet = false;
    
    if((Integer) mIdMappedValues.get(34) != null){
      lRet = true;
    }
      
    return lRet;
  }

}